<%@ Import Namespace="System.IO" %>
<script  runat="server">
Sub Page_Load(ByVal sender As Object, _
	ByVal e As EventArgs)
        Dim path As String = "c:\temp\MyTest.txt"
        If File.Exists(path) = False Then
            ' Create a file to write to.
            Dim sw As StreamWriter = _
	File.CreateText(path)
            sw.WriteLine("Hello<br />")
            sw.WriteLine("And<br />")
            sw.WriteLine("Welcome<br />")
            sw.Flush()
            sw.Close()
        End If

        Try
            ' Open the file to read from.
            Dim sr As StreamReader = _
	File.OpenText(path)
            Do While sr.Peek() >= 0
                Response.Write(sr.ReadLine())
            Loop
            sr.Close()
            Dim path2 As String = path + "temp"

            ' Ensure that the target does not exist.
            File.Delete(path2)

            ' Copy the file.
            File.Copy(path, path2)
            Response.Write("<br>File was copied to " + _
	path +  path2)

            ' Delete the newly created file.
            File.Delete(path2)
            Response.Write( _
	"<br>Process was successfully deleted.")

        Catch err As Exception
            Response.Write( _
	"<br>The process failed:" + err.ToString())
        End Try

End Sub
</script>


